#ifndef SCANNER
#define SCANNER
#include <stdio.h>
#include <ctype.h>
#include "token.h"
#include "buffer.h"
token scanner()
{
	int c;
	clearBuff();
	if(feof(stdin))
		return SCANEOF;
	while((c=getchar()) !=EOF)
	{
		if(isspace(c))continue;
		if(isalpha(c))
		{
			pushBuff(c);
			while(isalnum((c=getchar())))
				pushBuff(c);
			ungetc(c,stdin);
			return check_keyword();
		}
		if(isdigit(c))
		{
			pushBuff(c);
			while(isdigit((c=getchar())))
				pushBuff(c);
			ungetc(c,stdin);
			return DIGIT;
		}
		if(c==';')
			return SEMICOLON;
		if(c==':')
			return COLON;
		if(c=='/')
			if((c=getchar())!='/')
			{	
				ungetc(c,stdin),post_error(lexical,'/',0);
				continue;
			}
			else
			{
				while((c=getchar())!='\n');
				ungetc(c,stdin);
				continue;
			}
		post_error(lexical,c,0);
	}
	return SCANEOF;
}
#endif
